<div class="content-section introduction">
    <div>
        <span class="feature-title">Slider</span>
        <span>Slider is a component to provide input using dragging of a handle.</span>
    </div>
</div>

<div class="content-section implementation">
    <h3 class="first">Basic: {{val1}}</h3>
    <p-slider [(ngModel)]="val1" [style]="{'width':'200px'}"></p-slider>

    <h3>Input: {{val2}}</h3>
    <input type="text" pInputText [(ngModel)]="val2" style="width:190px" readonly/>
    <p-slider [(ngModel)]="val2" [style]="{'width':'200px'}"></p-slider>

    <h3>Animate: {{val3}}</h3>
    <p-slider [(ngModel)]="val3" [style]="{'width':'200px'}" [animate]="true"></p-slider>

    <h3>Step: {{val4}}</h3>
    <p-slider [(ngModel)]="val4" [style]="{'width':'200px'}" [step]="20"></p-slider>

    <h3>Range: {{rangeValues[0] + ' - ' + rangeValues[1]}}</h3>
    <p-slider [(ngModel)]="rangeValues" [style]="{'width':'200px'}" [range]="true"></p-slider>

    <h3>Vertical: {{val5}}</h3>
    <p-slider [(ngModel)]="val5" [style]="{'height':'200px'}" orientation="vertical"></p-slider>
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header="Documentation">
            <h3>Import</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;SliderModule&#125; from 'primeng/primeng';
</code>
</pre>

            <h3>Getting Started</h3>
            <p>Two-way binding is defined using the standard ngModel directive.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-slider [(ngModel)]="val"&gt;&lt;/p-slider&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MyModel &#123;

    val: number;

&#125;
</code>
</pre>

            <h3>Model Driven Forms</h3>
            <p>Slider can be used in a model driven form as well.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-slider formControlName="age"&gt;&lt;/p-slider&gt;
</code>
</pre>

            <h3>Min-Max</h3>
            <p>Boundaries are specified with min and max attributes.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-slider [(ngModel)]="val" [min]="0" [max]="100"&gt;&lt;/p-slider&gt;
</code>
</pre>

            <h3>Step</h3>
            <p>Step factor is 1 by default and can be customized with step option.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-slider [(ngModel)]="val" [step]="10"&gt;&lt;/p-slider&gt;
</code>
</pre>

            <h3>Range</h3>
            <p>Range slider provides two handles to define two values. In this case, value binding should refer to an array.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-slider [(ngModel)]="rangeValues" [range]="true"&gt;&lt;/p-slider&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MyModel &#123;

    rangeValues: number[];

&#125;
</code>
</pre>

            <h3>Orientation</h3>
            <p>Sliders supports two orientations, horizontal is the default and other alternative is vertical.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-slider [(ngModel)]="val" orientation="vertical"&gt;&lt;/p-slider&gt;
</code>
</pre>

            <h3>Properties</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>animate</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When enabled, displays an animation on click of the slider bar.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the element should be disabled.</td>
                        </tr>
                        <tr>
                            <td>min</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Mininum boundary value.</td>
                        </tr>
                        <tr>
                            <td>max</td>
                            <td>number</td>
                            <td>100</td>
                            <td>Maximum boundary value.</td>
                        </tr>
                        <tr>
                            <td>orientation</td>
                            <td>string</td>
                            <td>horizontal</td>
                            <td>Orientation of the slider, valid values are horizontal and vertical.</td>
                        </tr>
                        <tr>
                            <td>step</td>
                            <td>number</td>
                            <td>1</td>
                            <td>Step factor to increment/decrement the value.</td>
                        </tr>
                        <tr>
                            <td>range</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When speficed, allows two boundary values to be picked.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Events</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onChange</td>
                            <td>
                                event.originalEvent: Slide event <br />
                                event.value: New value <br />
                                event.values: Values in range mode <br />
                            </td>
                            <td>Callback to invoke on value change via slide.</td>
                        </tr>
                        <tr>
                            <td>onSlideEnd</td>
                            <td>
                                event.originalEvent: Mouseup event<br />
                                event.value: New value 
                            </td>
                            <td>Callback to invoke when slide stops.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-slider [(ngModel)]="val" (onChange)="handleChange($event)"&gt;&lt;/p-slider&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
handleChange(e) &#123;
    //e.value is the new value
&#125;
</code>
</pre>

            <h3>Styling</h3>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>ui-slider</td>
                            <td>Container element</td>
                        </tr>
                        <tr>
                            <td>ui-slider-handle</td>
                            <td>Handle element</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Dependencies</h3>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/slider" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;h3 class="first"&gt;Basic: {{val1}}&lt;/h3&gt;
&lt;p-slider [(ngModel)]="val1" [style]="&#123;'width':'200px'&#125;"&gt;&lt;/p-slider&gt;

&lt;h3&gt;Input: {{val2}}&lt;/h3&gt;
&lt;input type="text" pInputText [(ngModel)]="val2" style="width:190px"/&gt;
&lt;p-slider [(ngModel)]="val2" [style]="&#123;'width':'200px'&#125;"&gt;&lt;/p-slider&gt;

&lt;h3&gt;Animate: {{val3}}&lt;/h3&gt;
&lt;p-slider [(ngModel)]="val3" [style]="&#123;'width':'200px'&#125;" [animate]="true"&gt;&lt;/p-slider&gt;

&lt;h3&gt;Step: {{val4}}&lt;/h3&gt;
&lt;p-slider [(ngModel)]="val4" [style]="&#123;'width':'200px'&#125;" [step]="20"&gt;&lt;/p-slider&gt;

&lt;h3&gt;Range: {{rangeValues[0] + ' - ' + rangeValues[1]}}&lt;/h3&gt;
&lt;p-slider [(ngModel)]="rangeValues" [style]="&#123;'width':'200px'&#125;" [range]="true"&gt;&lt;/p-slider&gt;

&lt;h3&gt;Vertical: {{val5}}&lt;/h3&gt;
&lt;p-slider [(ngModel)]="val5" [style]="&#123;'height':'200px'&#125;" orientation="vertical"&gt;&lt;/p-slider&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class SliderDemo &#123;

    val1: number;

    val2: number = 50;

    val3: number;

    val4: number;

    val5: number;

    rangeValues: number[] = [20,80];
&#125;
</code>
</pre>
        </p-tabPanel>
    </p-tabView>
</div>
